package com.gccloud.design.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gccloud.design.entity.DICReasonEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 实现功能【障碍原因持久层】
 *
 * @author hu.hongdou
 * @date 2022/2/21
 */
@Mapper
public interface DICReasonDao extends BaseMapper<DICReasonEntity> {

    /**
     * 查询所有障碍原因
     *
     * @return 列表
     */
    @Select("select reason_id id,p_reason_id parentId,reason_name label from dic_reason where del_flag = 0")
    List<DICReasonEntity> selectAll();

    /**
     * 基于障碍原因标识查询障碍原因实体
     *
     * @param reasonId 障碍原因标识
     * @return 障碍原因实体
     */
    @Select("select reason_id id, reason_name label from dic_reason where reason_id = #{reasonId} and del_flag = 0")
    DICReasonEntity selectOneReason(Integer reasonId);
}
